#pragma once
#include "MessagePumpForUI.h"
#include "MessageLoop.h"

namespace xBase
{
    class CxMessageLoopForUI : public CxMessageLoop
    {
    public:
        CxMessageLoopForUI();
        CxMessageLoopForUI(const std::string & strThreadName);

        // Returns the MessageLoopForUI of the current thread.
        static CxMessageLoopForUI* Current()
        {
            CxMessageLoop* pMessageLoop = CxMessageLoop::Current();
            return static_cast<CxMessageLoopForUI*>(pMessageLoop);
        }

        VOID PumpOutPendingPaintMessages();

        VOID Run(IxDispatcher * pDispatcher);

        BOOL AddMsgFilter(CxMessageFilter * pMsgFilter)
        {
            return PumpUI()->AddMsgFilter(pMsgFilter);
        }

        BOOL RemoveMsgFilter(CxMessageFilter * pMsgFilter)
        {
            return PumpUI()->RemoveMsgFilter(pMsgFilter);
        }

        BOOL ProcessMessage(const MSG& msg)
        {
            return PumpUI()->ProcessMessage(msg);
        }

    protected:
        CxMessagePumpForUI * PumpUI()
        {
            return static_cast<CxMessagePumpForUI*>(m_Pump.get());
        }
    };
}